#include "gx_lock.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(void)
{
	//int fd = open("/var/run/test_lock.pid",O_RDWR|O_CREAT|O_APPEND,0700);
	lockfile("test_lock");
	/*
	int fd = open("gaoxin",O_RDWR|O_CREAT,0777);

	if( fd == 0)
	{
		perror("open");
		exit(1);
	}
	*/
	
	/*
	if(read_lock(fd,SEEK_SET,0,0)!=0)
	{
		perror("read_lock");
		exit(1);
	}
	*/

	/*
	int pid;
	if((pid=test_lock(fd,F_WRLCK,SEEK_SET,0,0)) == 0)
	{
		//printf("no lock\n");
	}
	else
	{
		printf("pid:%d\n",pid);
	}
	if(is_read_lockable(fd,SEEK_SET,0,0) == 0)
	{

		printf("no lock\n");
	}

	if(is_write_lockable(fd,SEEK_SET,0,0) == 0)
	{
		printf("no lock\n");
	}
	
	
	if(write_lock(fd,SEEK_SET,0,0) != 0)
	{
		perror("write_lock");
		exit(1);
	}
	*/

	while(1)
	{
	}

	/*
	if(un_lock(fd,SEEK_SET,0,0) != 0)
	{
		perror("un_lock");
		exit(1);
	}
	*/
	
	return 0;
}
